package dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import dao.UserDao;
import dbutil.Dbutil;
import entity.Hero;

public class UserDaoImpl  implements UserDao{

	
	public List<Hero> find() throws SQLException {
		Connection conn = Dbutil.getConn();
		String sql = "select * from bbc";
		List<Hero> list = new ArrayList<Hero>();
		PreparedStatement pst = conn.prepareStatement(sql);
		ResultSet rs = pst.executeQuery();
		while(rs.next()){
			String name = rs.getString(1);
			String region = rs.getString(2);
			String area = rs.getString(3);
			String population = rs.getString(4);
			Hero h = new Hero(name, region, area, population);
			list.add(h);
		}
		conn.close();
		return list;
	}

}
